package com.hisky.cms.menu.dao;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.hisky.basic.dao.BaseDao;
import com.hisky.cms.menu.vo.Menu;

@Repository
public class MenuDao extends BaseDao {
	private static Logger logger = Logger.getLogger(MenuDao.class);

	public int add(Menu menu) {
		sqlSession.insert("Menu.add", menu);
		logger.debug("add success..." + menu);
		return menu.getMenuId();
	}

	public int update(Menu menu) {
		int count = sqlSession.update("Menu.update", menu);
		logger.debug("update success..." + count);
		return count;
	}

	public List<Menu> getList(Menu menu) {
		List<Menu> list = sqlSession.selectList("Menu.getList", menu);
		logger.debug("getList success..." + list.size());
		return list;
	}

	public Menu get(int menuId) {
		Menu menu = sqlSession.selectOne("Menu.get", menuId);
		logger.debug("get success..." + menu);
		return menu;
	}

	public Menu getPrevious(Menu menu) {
		return sqlSession.selectOne("Menu.getPrevious", menu);
	}

	public Menu getNext(Menu menu) {
		return sqlSession.selectOne("Menu.getNext", menu);
	}
}
